package com.fly.toolbox.component;

import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.FormBuilder;

import javax.swing.*;

public class AppSettingsComponent {

    private final JPanel myMainPanel;
    private final JBTextField userText = new JBTextField();
    private final JBTextField versionsText = new JBTextField();
    private final JBTextField baseClassPathText = new JBTextField();
    private final JBTextField exportFilePathText = new JBTextField();
    private final JBCheckBox clearHistoryStatus = new JBCheckBox("Clear history?");

    public AppSettingsComponent() {
        myMainPanel = FormBuilder.createFormBuilder()
                .addLabeledComponent(new JBLabel("Enter user name: "), userText, 1, false)
                .addLabeledComponent(new JBLabel("Enter versions: "), versionsText, 1, false)
                .addLabeledComponent(new JBLabel("Enter base class path: "), baseClassPathText, 1, false)
                .addLabeledComponent(new JBLabel("Enter export file path: "), exportFilePathText, 1, false)
                .addComponent(clearHistoryStatus, 1)
                .addComponentFillVertically(new JPanel(), 0)
                .getPanel();
    }

    public JPanel getPanel() {
        return myMainPanel;
    }

    public JComponent getPreferredFocusedComponent() {
        return userText;
    }

    public String getUserText() {
        return userText.getText();
    }

    public void setUserText(String newText) {
        userText.setText(newText);
    }

    public boolean getClearHistoryStatus() {
        return clearHistoryStatus.isSelected();
    }

    public void setClearHistoryStatus(boolean newStatus) {
        clearHistoryStatus.setSelected(newStatus);
    }

    public String getVersionsText() {
        return versionsText.getText();
    }

    public void setVersionsText(String newText) {
        versionsText.setText(newText);
    }

    public String getBaseClassPathText() {
        return baseClassPathText.getText();
    }

    public void setBaseClassPathText(String newText) {
        baseClassPathText.setText(newText);
    }

    public String getExportFilePathText() {
        return exportFilePathText.getText();
    }

    public void setExportFilePathText(String newText) {
        exportFilePathText.setText(newText);
    }

}